<template>
    <view :class="$style.box">
        <view>
            <uni-easyinput type="textarea" v-model="formData.content" placeholder="期望您的意见或建议"></uni-easyinput>
        </view>
        <view class="m-t-20">
            <uni-easyinput type="text" v-model="formData.tel" placeholder="您的联系方式"></uni-easyinput>
        </view>
        <view class="m-t-30">
            <button type="primary" @click="submit">提交</button>
        </view>
    </view>
</template>

<script lang="ts" setup>
import { submitApi } from '@/api/Feedback';
import { ref } from 'vue';


    const formData = ref({
        content : '',
        tel : ''
    })
    function submit() {
        if(formData.value.content.length == 0) {
            uni.showToast({
                icon : 'none',
                title : '请填写反馈内容'
            })

            return
        }

        uni.showLoading()
        submitApi(formData.value).then(r => {
            uni.hideLoading()
            if(r.success) {
                uni.showModal({
                    content:'谢谢您的反馈，我们将会尽快跟进处理',
                    showCancel:false,
                    success:(success)=>{
                        uni.navigateBack()
                    },
                })
            }
        })

    }
</script>

<style lang="scss" module>
    .box{
        padding: $base-space;
    }
</style>